
//
//  GCTitleBtn.m
//  自定义Btn
//
//  Created by apple on 15/11/25.
//  Copyright © 2015年 xuguangChao. All rights reserved.
//

#import "GCTitleBtn.h"
#import "UIImage+MJ.h"

#define IWTitleButtonImageW 74*0.383
#define IWTitleButtonImageH 74*0.383

@implementation GCTitleBtn

+ (instancetype)titleButton
{
    return [[self alloc] init];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 高亮的时候不要自动调整图标
        self.adjustsImageWhenHighlighted = NO;
        self.titleLabel.font = NormalFont(40);
        self.imageView.contentMode = UIViewContentModeCenter;
        self.titleLabel.textAlignment = NSTextAlignmentRight;
        // 背景
        [self setBackgroundImage:[UIImage resizedImageWithName:@"navigationbar_filter_background_highlighted"] forState:UIControlStateHighlighted];
        [self setTitleColor:Color333333 forState:UIControlStateNormal];
    }
    return self;
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat imageY = contentRect.size.height/2 - IWTitleButtonImageH+2;
    CGFloat imageW = IWTitleButtonImageW;
    CGFloat imageX = contentRect.size.width/2 - IWTitleButtonImageW/2;
    CGFloat imageH = IWTitleButtonImageW;
    
    return CGRectMake(imageX, imageY, imageW, imageH);
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    
    CGFloat titleY = contentRect.size.height/2+30*0.383;
    CGFloat titleX = 0;
    CGFloat titleW = contentRect.size.width;
    CGFloat titleH = 20;
    return CGRectMake(titleX, titleY, titleW, titleH);
}



@end
